/**
 * @see https://umijs.org/docs/max/access#access
 * */
export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
  const { currentUser } = initialState ?? {};
  return {
    // 管理员权限：userRole === 1
    canAdmin: currentUser && currentUser.userRole === 1,
    // 普通用户权限：userRole === 0
    canUser: currentUser && currentUser.userRole === 0,
    // 所有登录用户都有权限
    isLogin: !!currentUser,
  };
}
